<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@taglib uri="http://www.goodfox.com/jsp/tags/power" prefix="p"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<script type="text/javascript">
$(function(){
	loadOrgTree("orgTreeLookup");
});
function loadOrgTree(orgTreeId){
	$.ajax({
    	"dataType": "json",
    	"type": "POST",
    	"url": "<c:url value="/organization/organizationTreeQuery.shtml"/>",
    	"data": "",
    	async: false,
    	"success": function(data){
    		for(var i=0;i<data.orgList.length;i++){
    			var org=data.orgList[i];
    			var back="orgId:'"+org.orgId+"',orgName:'"+org.orgName+"',orgGrade:'"+org.orgGrade+"'";
    			if(org.orgId==data.curOrgId){
    				var topUl="<li><a href='javascript:' onclick=\"$.bringBack({"+back+"})\">"+org.orgName+"</a><ul id='"+orgTreeId+"_"+org.orgId+"'></ul></li>";
    				if(org.subCount==0){
    					topUl="<li><a href='javascript:' onclick=\"$.bringBack({"+back+"})\">"+org.orgName+"</a></li>";
    				}
    				$("#"+orgTreeId).append(topUl);
    			}else{
    				var ul="<li><a href='javascript:' onclick=\"$.bringBack({"+back+"})\">"+org.orgName+"</a><ul id='"+orgTreeId+"_"+org.orgId+"'></ul></li>";
    				if(org.subCount==0){
    					ul="<li><a href='javascript:' onclick=\"$.bringBack({"+back+"})\">"+org.orgName+"</a></li>";
    				}
    				$("#"+orgTreeId+"_"+org.orgIdParent).append(ul);
    			}
    		}
    	}
    }); 
}
</script>
<div class="pageContent">
	<div class="pageFormContent" layoutH="58">
		<ul id="orgTreeLookup" class="tree expand">
		</ul>
	</div>
	<div class="formBar">
		<ul>
			<li><div class="button"><div class="buttonContent"><button class="close" type="button"><spring:message code="page.btnClose"/></button></div></div></li>
		</ul>
	</div>
</div>